package com.yulongtian.oneProblemEveryDay.month202301;

/**
 * https://leetcode.cn/problems/counting-words-with-a-given-prefix/
 * 可
 *
 * @author yulongTian
 * @create 2023-01-09 10:31
 */
public class Test07 {
    public static void main(String[] args) {
        String[] words = {"pay", "attention", "practice", "attend"};
        String pref = "at";
        System.out.println(prefixCount(words, pref));
    }

    public static int prefixCount(String[] words, String pref) {
        int sLen = pref.length();
        int ans = 0;
        for (String word : words) {
            if (sLen <= word.length() && pref.equals(word.substring(0, sLen))) {
                ans++;
            }
        }
        return ans;
    }
}
